<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<script src="../../resources/js-test.js"></script>
<input id="input" type="input">
<script type="text/javascript">
description('Test that composition events should have a sourceCapabilities and its firesTouchEvents should always be false.');

function compositionHandler() {
    debug(event.type);
    shouldBeNonNull("event.sourceCapabilities");
    shouldBeFalse("event.sourceCapabilities.firesTouchEvents");
}

if (window.eventSender) {
    for (var evt of ['compositionstart', 'compositionupdate', 'compositionend']) {
        document.addEventListener(evt, compositionHandler);
    }

    var input = document.getElementById('input');
    input.focus();

    // We need to force a text input update here so that later the call to
    // RenderWidget::resetInputMethod() will lead to finishComposingText().
    // Normally this would not be needed if the focus was due to user gesture.
    // But on Mac, even with user gesture, we wait for the next compositing
    // to update text input state frame. That is why we are explicitly calling
    // this method here.
    textInputController.forceTextInputStateUpdate();

    textInputController.setMarkedText('abcde', 1, 3);

    input.blur();
} else {
   debug('This test requires eventSender.');
}

</script>
